package edu.xpu.cs.hub.service;


import edu.xpu.cs.hub.entity.Node;
import edu.xpu.cs.hub.entity.Process;
import edu.xpu.cs.hub.mapper.NodeMapper;
import edu.xpu.cs.hub.mapper.ProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
@Component
public class ProcessService {

    @Autowired
    private ProcessMapper processMapper;

    //插入
    public int insertProcess2sql(String id, String name, String url, String location, Date date,String category){
        System.out.print("开始插入=id=="+id+"\n");
        System.out.print("开始插入=name=="+name+"\n");
        System.out.print("开始插入=url=="+url+"\n");
        System.out.print("开始插入=location=="+location+"\n");
        System.out.println("开始插入=date=="+date+"\n");
        int result= processMapper.insertProcess2sql(id,name,url,location,date,category);
        System.out.print("插入结果==="+result+"\n");
        return result;
    }

    //查询
    public List<Process> selectAll(){
        List<Process> processes= processMapper.selectAll();
        return  processes;
    }

    public String deleteProcess(String name){
        return processMapper.deleteProcess(name);
    }

    public List<Process> processInfo(String nodesName){
        return processMapper.processInfo(nodesName);
    }
}
